#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>

#include <unistd.h>
#include <sys/un.h>
#include <sys/socket.h>

#define PATH "/home/windy/domainsock"

int main() {
	int sockfd = 0;
	struct sockaddr_un addr;
	
	addr.sun_family = AF_UNIX;
	strcpy(addr.sun_path, PATH);

	unsigned int len = strlen(addr.sun_path) + \
								sizeof(addr.sun_family);
	sockfd = socket(AF_UNIX, SOCK_DGRAM, 0);
	bind(sockfd, (struct sockaddr*)&addr, len);

	while (1) {
        static int counter = 0;
        char send_buf[20] = "test";
        counter++;
        sprintf(send_buf,"Counter is %d",counter);
        int len = strlen(addr.sun_path)+sizeof(addr.sun_family);
        sendto(sockfd,send_buf,strlen(send_buf),0,(struct sockaddr*)&addr,len);
        printf("Send: %s\n",send_buf);
        sleep(1);
	}
	return 0;
}